<?php
/**
 * Created by PhpStorm.
 * User: sks
 * Date: 2015/12/15
 * Time: 13:49
 */

class Involved_ShopModel extends BaseModel{

    protected $table = 'category';

    /**
     *分类列表
     * @return mixed
     */
    public function CatesList()
    {
        return  DB::table($this->table)
               //->where('fid','>','0')
                ->where('statue',1)
                ->get();
    }
    public function SelectCategory($id,$fids){
        return DB::table($this->table)
            ->select('cate_name')
            ->where('c_id',$fids)
            ->where('statue',1)
            ->first();
    }

    /**
     *父级分类
     * @return mixed
     */
    public function CatListfa()
    {
        return  DB::table($this->table)
            ->where('fid',0)
            ->where('statue',1)
            ->get();
    }
    /**
     *是否存在ID
     * @return mixed
     */
    public function CatFirst($id){
          $data=DB::table($this->table)
            ->where('c_id',$id)
              ->where('statue',1)
            ->first();
        //dd($data);
       return $data;
    }
    /**
     *查询是子级还是父级
     * @return mixed
     */
    public function FatherCategory($id){
        $data=DB::table($this->table)
            ->select('fid')
            ->where('c_id',$id)
            ->where('statue',1)
            ->first();
        //dd($data);
        return $data;
    }


    /**
     *查询是父级下面的子级
     * @return mixed
     */
    public function ParpentCategory($id){
        $data=DB::table($this->table)
            ->select('c_id')
            ->where('fid',$id)
            ->where('statue',1)
            ->get();
        //dd($data);
        return $data;
    }


}